var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
    devtool: 'source-map',
    entry:{
        index:[
            // 'babel-polyfill',
            path.resolve(__dirname,'src/index.js')
        ],
        // button:[
        //     // 'babel-polyfill',
        //     path.resolve(__dirname,'src/Button/index.js')            
        // ]
    },
    output:{
        path:path.resolve(__dirname,'lib'),
        filename:"[name].js",
        libraryTarget:'umd'
        // libraryTarget: 'umd'
        // filename:"bundle.js"
    },
    devServer: {
        historyApiFallback: true,
        hot: true,
        inline: true,
        stats: { colors: true }
    },
    module:{
        rules:[
            {
                loader:'babel-loader',
                exclude:[ path.resolve(__dirname,'node_modules') ],
                include:[ path.resolve(__dirname,'src') ],
                test:/\.(js)$/,
                query:{
                    presets:['es2015','stage-0']
                }
            },
            {
                test: /\.(vue)$/,
                loader: 'vue-loader'
            },
            {
                test: /\.(png|jpg)$/,
                loader: 'url-loader?limit=25000',
            },
            // {
            //     test: /\.css$/,
            //     loader: 'style-loader!css-loader'
            // },
            {
              test: /\.css$/,
              use: ExtractTextPlugin.extract({
                fallback: "style-loader",
                use: "css-loader"
              })
            },
            {   test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url-loader?limit=10000&mimetype=application/font-woff"
            },
            {   test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, 
                loader: "url-loader?limit=10000&mimetype=application/font-woff2"
            },
            {   test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, 
                loader: "url-loader?limit=10000&mimetype=application/octet-stream"
            },
            {   test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, 
                loader: "file-loader"
            },
            {   test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, 
                loader: "url-loader?limit=10000&mimetype=image/svg+xml"
            },
        ]
    },
    plugins: [
      new ExtractTextPlugin("acd.css"),
    ],
    resolve:{
        extensions:['.js','.vue','.json'],
        alias: {
          'vue$': 'vue/dist/vue.esm.js'
        }
    },
    externals: {
        vue: 'vue',
        echarts:'echarts'
    }
};